<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="expaterror-objects.html" />
<link rel="prev" href="module-xml.parsers.expat.html" />
<link rel="parent" href="module-xml.parsers.expat.html" />
<link rel="next" href="expaterror-objects.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>8.5.1 XMLParser Objects </title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="8.5 xml.parsers.expat  "
  href="module-xml.parsers.expat.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="8.5 xml.parsers.expat  "
  href="module-xml.parsers.expat.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="8.5.2 expaterror Exceptions"
  href="expaterror-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-xml.parsers.expat.html">8.5 xml.parsers.expat  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-xml.parsers.expat.html">8.5 xml.parsers.expat  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="expaterror-objects.html">8.5.2 ExpatError Exceptions</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h2><a name="SECTION0010510000000000000000"></a><a name="xmlparser-objects"></a>
<br>
8.5.1 XMLParser Objects 
</h2>

<p>
<tt class="class">xmlparser</tt> objects have the following methods:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1720' xml:id='l2h-1720' class="method">Parse</tt></b>(</nobr></td>
  <td><var>data</var><big>[</big><var>, isfinal</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Parses the contents of the string <var>data</var>, calling the appropriate
handler functions to process the parsed data.  <var>isfinal</var> must be
true on the final call to this method.  <var>data</var> can be the empty
string at any time.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1721' xml:id='l2h-1721' class="method">ParseFile</tt></b>(</nobr></td>
  <td><var>file</var>)</td></tr></table></dt>
<dd>
Parse XML data reading from the object <var>file</var>.  <var>file</var> only
needs to provide the <tt class="method">read(<var>nbytes</var>)</tt> method, returning the
empty string when there's no more data.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1722' xml:id='l2h-1722' class="method">SetBase</tt></b>(</nobr></td>
  <td><var>base</var>)</td></tr></table></dt>
<dd>
Sets the base to be used for resolving relative URIs in system
identifiers in declarations.  Resolving relative identifiers is left
to the application: this value will be passed through as the
<var>base</var> argument to the <tt class="function">ExternalEntityRefHandler</tt>,
<tt class="function">NotationDeclHandler</tt>, and
<tt class="function">UnparsedEntityDeclHandler</tt> functions.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1723' xml:id='l2h-1723' class="method">GetBase</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns a string containing the base set by a previous call to
<tt class="method">SetBase()</tt>, or <code>None</code> if 
<tt class="method">SetBase()</tt> hasn't been called.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1724' xml:id='l2h-1724' class="method">GetInputContext</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns the input data that generated the current event as a string.
The data is in the encoding of the entity which contains the text.
When called while an event handler is not active, the return value is
<code>None</code>.

<span class="versionnote">New in version 2.1.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1725' xml:id='l2h-1725' class="method">ExternalEntityParserCreate</tt></b>(</nobr></td>
  <td><var>context</var><big>[</big><var>,
                                                          encoding</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Create a ``child'' parser which can be used to parse an external
parsed entity referred to by content parsed by the parent parser.  The
<var>context</var> parameter should be the string passed to the
<tt class="method">ExternalEntityRefHandler()</tt> handler function, described below.
The child parser is created with the <tt class="member">ordered_attributes</tt>,
<tt class="member">returns_unicode</tt> and <tt class="member">specified_attributes</tt> set to the
values of this parser.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1726' xml:id='l2h-1726' class="method">UseForeignDTD</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>flag</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Calling this with a true value for <var>flag</var> (the default) will cause
Expat to call the <tt class="member">ExternalEntityRefHandler</tt> with
<tt class="constant">None</tt> for all arguments to allow an alternate DTD to be
loaded.  If the document does not contain a document type declaration,
the <tt class="member">ExternalEntityRefHandler</tt> will still be called, but the
<tt class="member">StartDoctypeDeclHandler</tt> and <tt class="member">EndDoctypeDeclHandler</tt>
will not be called.

<p>
Passing a false value for <var>flag</var> will cancel a previous call that
passed a true value, but otherwise has no effect.

<p>
This method can only be called before the <tt class="method">Parse()</tt> or
<tt class="method">ParseFile()</tt> methods are called; calling it after either of
those have been called causes <tt class="exception">ExpatError</tt> to be raised with
the <tt class="member">code</tt> attribute set to
<tt class="constant">errors.XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING</tt>.

<p>

<span class="versionnote">New in version 2.3.</span>

</dl>

<p>
<tt class="class">xmlparser</tt> objects have the following attributes:

<p>
<dl><dt><b><tt id='l2h-1727' xml:id='l2h-1727' class="member">buffer_size</tt></b></dt>
<dd>
The size of the buffer used when <tt class="member">buffer_text</tt> is true.  This
value cannot be changed at this time.

<span class="versionnote">New in version 2.3.</span>

</dl>

<p>
<dl><dt><b><tt id='l2h-1728' xml:id='l2h-1728' class="member">buffer_text</tt></b></dt>
<dd>
Setting this to true causes the <tt class="class">xmlparser</tt> object to buffer
textual content returned by Expat to avoid multiple calls to the
<tt class="method">CharacterDataHandler()</tt> callback whenever possible.  This can
improve performance substantially since Expat normally breaks
character data into chunks at every line ending.  This attribute is
false by default, and may be changed at any time.

<span class="versionnote">New in version 2.3.</span>

</dl>

<p>
<dl><dt><b><tt id='l2h-1729' xml:id='l2h-1729' class="member">buffer_used</tt></b></dt>
<dd>
If <tt class="member">buffer_text</tt> is enabled, the number of bytes stored in the
buffer.  These bytes represent UTF-8 encoded text.  This attribute has
no meaningful interpretation when <tt class="member">buffer_text</tt> is false.

<span class="versionnote">New in version 2.3.</span>

</dl>

<p>
<dl><dt><b><tt id='l2h-1730' xml:id='l2h-1730' class="member">ordered_attributes</tt></b></dt>
<dd>
Setting this attribute to a non-zero integer causes the attributes to
be reported as a list rather than a dictionary.  The attributes are
presented in the order found in the document text.  For each
attribute, two list entries are presented: the attribute name and the
attribute value.  (Older versions of this module also used this
format.)  By default, this attribute is false; it may be changed at
any time.

<span class="versionnote">New in version 2.1.</span>

</dl>

<p>
<dl><dt><b><tt id='l2h-1731' xml:id='l2h-1731' class="member">returns_unicode</tt></b></dt>
<dd> 
If this attribute is set to a non-zero integer, the handler functions
will be passed Unicode strings.  If <tt class="member">returns_unicode</tt> is
<tt class="constant">False</tt>, 8-bit strings containing UTF-8 encoded data will be
passed to the handlers.  This is <tt class="constant">True</tt> by default when
Python is built with Unicode support.

<span class="versionnote">Changed in version 1.6:
Can be changed at any time to affect the result
  type.</span>

</dl>

<p>
<dl><dt><b><tt id='l2h-1732' xml:id='l2h-1732' class="member">specified_attributes</tt></b></dt>
<dd>
If set to a non-zero integer, the parser will report only those
attributes which were specified in the document instance and not those
which were derived from attribute declarations.  Applications which
set this need to be especially careful to use what additional
information is available from the declarations as needed to comply
with the standards for the behavior of XML processors.  By default,
this attribute is false; it may be changed at any time.

<span class="versionnote">New in version 2.1.</span>

</dl>

<p>
The following attributes contain values relating to the most recent
error encountered by an <tt class="class">xmlparser</tt> object, and will only have
correct values once a call to <tt class="method">Parse()</tt> or <tt class="method">ParseFile()</tt>
has raised a <tt class="exception">xml.parsers.expat.ExpatError</tt> exception.

<p>
<dl><dt><b><tt id='l2h-1733' xml:id='l2h-1733' class="member">ErrorByteIndex</tt></b></dt>
<dd> 
Byte index at which an error occurred.
</dl> 

<p>
<dl><dt><b><tt id='l2h-1734' xml:id='l2h-1734' class="member">ErrorCode</tt></b></dt>
<dd> 
Numeric code specifying the problem.  This value can be passed to the
<tt class="function">ErrorString()</tt> function, or compared to one of the constants
defined in the <code>errors</code> object.
</dl>

<p>
<dl><dt><b><tt id='l2h-1735' xml:id='l2h-1735' class="member">ErrorColumnNumber</tt></b></dt>
<dd> 
Column number at which an error occurred.
</dl>

<p>
<dl><dt><b><tt id='l2h-1736' xml:id='l2h-1736' class="member">ErrorLineNumber</tt></b></dt>
<dd>
Line number at which an error occurred.
</dl>

<p>
The following attributes contain values relating to the current parse
location in an <tt class="class">xmlparser</tt> object.  During a callback reporting
a parse event they indicate the location of the first of the sequence
of characters that generated the event.  When called outside of a
callback, the position indicated will be just past the last parse
event (regardless of whether there was an associated callback).

<span class="versionnote">New in version 2.4.</span>

<p>
<dl><dt><b><tt id='l2h-1737' xml:id='l2h-1737' class="member">CurrentByteIndex</tt></b></dt>
<dd> 
Current byte index in the parser input.
</dl> 

<p>
<dl><dt><b><tt id='l2h-1738' xml:id='l2h-1738' class="member">CurrentColumnNumber</tt></b></dt>
<dd> 
Current column number in the parser input.
</dl>

<p>
<dl><dt><b><tt id='l2h-1739' xml:id='l2h-1739' class="member">CurrentLineNumber</tt></b></dt>
<dd>
Current line number in the parser input.
</dl>

<p>
Here is the list of handlers that can be set.  To set a handler on an
<tt class="class">xmlparser</tt> object <var>o</var>, use
<code><var>o</var>.<var>handlername</var> = <var>func</var></code>.  <var>handlername</var> must
be taken from the following list, and <var>func</var> must be a callable
object accepting the correct number of arguments.  The arguments are
all strings, unless otherwise stated.

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1740' xml:id='l2h-1740' class="method">XmlDeclHandler</tt></b>(</nobr></td>
  <td><var>version, encoding, standalone</var>)</td></tr></table></dt>
<dd>
Called when the XML declaration is parsed.  The XML declaration is the
(optional) declaration of the applicable version of the XML
recommendation, the encoding of the document text, and an optional
``standalone'' declaration.  <var>version</var> and <var>encoding</var> will be
strings of the type dictated by the <tt class="member">returns_unicode</tt>
attribute, and <var>standalone</var> will be <code>1</code> if the document is
declared standalone, <code>0</code> if it is declared not to be standalone,
or <code>-1</code> if the standalone clause was omitted.
This is only available with Expat version 1.95.0 or newer.

<span class="versionnote">New in version 2.1.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1741' xml:id='l2h-1741' class="method">StartDoctypeDeclHandler</tt></b>(</nobr></td>
  <td><var>doctypeName,
                                                       systemId, publicId,
                                                       has_internal_subset</var>)</td></tr></table></dt>
<dd>
Called when Expat begins parsing the document type declaration
(<code>&lt;!DOCTYPE ...</code>).  The <var>doctypeName</var> is provided exactly
as presented.  The <var>systemId</var> and <var>publicId</var> parameters give
the system and public identifiers if specified, or <code>None</code> if
omitted.  <var>has_internal_subset</var> will be true if the document
contains and internal document declaration subset.
This requires Expat version 1.2 or newer.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1742' xml:id='l2h-1742' class="method">EndDoctypeDeclHandler</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Called when Expat is done parsing the document type declaration.
This requires Expat version 1.2 or newer.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1743' xml:id='l2h-1743' class="method">ElementDeclHandler</tt></b>(</nobr></td>
  <td><var>name, model</var>)</td></tr></table></dt>
<dd>
Called once for each element type declaration.  <var>name</var> is the name
of the element type, and <var>model</var> is a representation of the
content model.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1744' xml:id='l2h-1744' class="method">AttlistDeclHandler</tt></b>(</nobr></td>
  <td><var>elname, attname,
                                                  type, default, required</var>)</td></tr></table></dt>
<dd>
Called for each declared attribute for an element type.  If an
attribute list declaration declares three attributes, this handler is
called three times, once for each attribute.  <var>elname</var> is the name
of the element to which the declaration applies and <var>attname</var> is
the name of the attribute declared.  The attribute type is a string
passed as <var>type</var>; the possible values are <code>'CDATA'</code>,
<code>'ID'</code>, <code>'IDREF'</code>, ...
<var>default</var> gives the default value for the attribute used when the
attribute is not specified by the document instance, or <code>None</code> if
there is no default value (<code>#IMPLIED</code> values).  If the attribute
is required to be given in the document instance, <var>required</var> will
be true.
This requires Expat version 1.95.0 or newer.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1745' xml:id='l2h-1745' class="method">StartElementHandler</tt></b>(</nobr></td>
  <td><var>name, attributes</var>)</td></tr></table></dt>
<dd>
Called for the start of every element.  <var>name</var> is a string
containing the element name, and <var>attributes</var> is a dictionary
mapping attribute names to their values.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1746' xml:id='l2h-1746' class="method">EndElementHandler</tt></b>(</nobr></td>
  <td><var>name</var>)</td></tr></table></dt>
<dd>
Called for the end of every element.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1747' xml:id='l2h-1747' class="method">ProcessingInstructionHandler</tt></b>(</nobr></td>
  <td><var>target, data</var>)</td></tr></table></dt>
<dd>
Called for every processing instruction.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1748' xml:id='l2h-1748' class="method">CharacterDataHandler</tt></b>(</nobr></td>
  <td><var>data</var>)</td></tr></table></dt>
<dd>
Called for character data.  This will be called for normal character
data, CDATA marked content, and ignorable whitespace.  Applications
which must distinguish these cases can use the
<tt class="member">StartCdataSectionHandler</tt>, <tt class="member">EndCdataSectionHandler</tt>,
and <tt class="member">ElementDeclHandler</tt> callbacks to collect the required
information.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1749' xml:id='l2h-1749' class="method">UnparsedEntityDeclHandler</tt></b>(</nobr></td>
  <td><var>entityName, base,
                                                         systemId, publicId,
                                                         notationName</var>)</td></tr></table></dt>
<dd>
Called for unparsed (NDATA) entity declarations.  This is only present
for version 1.2 of the Expat library; for more recent versions, use
<tt class="member">EntityDeclHandler</tt> instead.  (The underlying function in the
Expat library has been declared obsolete.)
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1750' xml:id='l2h-1750' class="method">EntityDeclHandler</tt></b>(</nobr></td>
  <td><var>entityName,
                                                 is_parameter_entity, value,
                                                 base, systemId,
                                                 publicId,
                                                 notationName</var>)</td></tr></table></dt>
<dd>
Called for all entity declarations.  For parameter and internal
entities, <var>value</var> will be a string giving the declared contents
of the entity; this will be <code>None</code> for external entities.  The
<var>notationName</var> parameter will be <code>None</code> for parsed entities,
and the name of the notation for unparsed entities.
<var>is_parameter_entity</var> will be true if the entity is a parameter
entity or false for general entities (most applications only need to
be concerned with general entities).
This is only available starting with version 1.95.0 of the Expat
library.

<span class="versionnote">New in version 2.1.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1751' xml:id='l2h-1751' class="method">NotationDeclHandler</tt></b>(</nobr></td>
  <td><var>notationName, base,
                                                   systemId, publicId</var>)</td></tr></table></dt>
<dd>
Called for notation declarations.  <var>notationName</var>, <var>base</var>, and
<var>systemId</var>, and <var>publicId</var> are strings if given.  If the
public identifier is omitted, <var>publicId</var> will be <code>None</code>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1752' xml:id='l2h-1752' class="method">StartNamespaceDeclHandler</tt></b>(</nobr></td>
  <td><var>prefix, uri</var>)</td></tr></table></dt>
<dd>
Called when an element contains a namespace declaration.  Namespace
declarations are processed before the <tt class="member">StartElementHandler</tt> is
called for the element on which declarations are placed.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1753' xml:id='l2h-1753' class="method">EndNamespaceDeclHandler</tt></b>(</nobr></td>
  <td><var>prefix</var>)</td></tr></table></dt>
<dd>
Called when the closing tag is reached for an element 
that contained a namespace declaration.  This is called once for each
namespace declaration on the element in the reverse of the order for
which the <tt class="member">StartNamespaceDeclHandler</tt> was called to indicate
the start of each namespace declaration's scope.  Calls to this
handler are made after the corresponding <tt class="member">EndElementHandler</tt>
for the end of the element.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1754' xml:id='l2h-1754' class="method">CommentHandler</tt></b>(</nobr></td>
  <td><var>data</var>)</td></tr></table></dt>
<dd>
Called for comments.  <var>data</var> is the text of the comment, excluding
the leading `<code>&lt;!-</code><code>-</code>' and trailing `<code>-</code><code>-&gt;</code>'.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1755' xml:id='l2h-1755' class="method">StartCdataSectionHandler</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Called at the start of a CDATA section.  This and
<tt class="member">EndCdataSectionHandler</tt> are needed to be able to identify
the syntactical start and end for CDATA sections.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1756' xml:id='l2h-1756' class="method">EndCdataSectionHandler</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Called at the end of a CDATA section.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1757' xml:id='l2h-1757' class="method">DefaultHandler</tt></b>(</nobr></td>
  <td><var>data</var>)</td></tr></table></dt>
<dd>
Called for any characters in the XML document for
which no applicable handler has been specified.  This means
characters that are part of a construct which could be reported, but
for which no handler has been supplied. 
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1758' xml:id='l2h-1758' class="method">DefaultHandlerExpand</tt></b>(</nobr></td>
  <td><var>data</var>)</td></tr></table></dt>
<dd>
This is the same as the <tt class="function">DefaultHandler</tt>, 
but doesn't inhibit expansion of internal entities.
The entity reference will not be passed to the default handler.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1759' xml:id='l2h-1759' class="method">NotStandaloneHandler</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd> Called if the
XML document hasn't been declared as being a standalone document.
This happens when there is an external subset or a reference to a
parameter entity, but the XML declaration does not set standalone to
<code>yes</code> in an XML declaration.  If this handler returns <code>0</code>,
then the parser will throw an <tt class="constant">XML_ERROR_NOT_STANDALONE</tt>
error.  If this handler is not set, no exception is raised by the
parser for this condition.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1760' xml:id='l2h-1760' class="method">ExternalEntityRefHandler</tt></b>(</nobr></td>
  <td><var>context, base,
                                                        systemId, publicId</var>)</td></tr></table></dt>
<dd>
Called for references to external entities.  <var>base</var> is the current
base, as set by a previous call to <tt class="method">SetBase()</tt>.  The public and
system identifiers, <var>systemId</var> and <var>publicId</var>, are strings if
given; if the public identifier is not given, <var>publicId</var> will be
<code>None</code>.  The <var>context</var> value is opaque and should only be
used as described below.

<p>
For external entities to be parsed, this handler must be implemented.
It is responsible for creating the sub-parser using
<code>ExternalEntityParserCreate(<var>context</var>)</code>, initializing it with
the appropriate callbacks, and parsing the entity.  This handler
should return an integer; if it returns <code>0</code>, the parser will
throw an <tt class="constant">XML_ERROR_EXTERNAL_ENTITY_HANDLING</tt> error,
otherwise parsing will continue.

<p>
If this handler is not provided, external entities are reported by the
<tt class="member">DefaultHandler</tt> callback, if provided.
</dl>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="8.5 xml.parsers.expat  "
  href="module-xml.parsers.expat.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="8.5 xml.parsers.expat  "
  href="module-xml.parsers.expat.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="8.5.2 expaterror Exceptions"
  href="expaterror-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-xml.parsers.expat.html">8.5 xml.parsers.expat  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-xml.parsers.expat.html">8.5 xml.parsers.expat  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="expaterror-objects.html">8.5.2 ExpatError Exceptions</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
